import babelpolyfill from 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//import './assets/theme/theme-green/index.css'
import VueRouter from 'vue-router'
import store from './vuex/store'
import Vuex from 'vuex'
//import NProgress from 'nprogress'
//import 'nprogress/nprogress.css'
import routes from './routes'
// import Mock from './mock'
// Mock.bootstrap();
import 'font-awesome/css/font-awesome.min.css'
import axios from "axios";

Vue.use(ElementUI)
Vue.use(VueRouter)
Vue.use(Vuex)

//vue prototype属性
// Vue.prototype.$http = axios

//反向代理
// axios.defaults.baseURL='/api'

//NProgress.configure({ showSpinner: false });

const router = new VueRouter({
    routes
})

//axios拦截器
//拦截请求，处理请求（赋值token）
// axios.interceptors.request.use(req => {
//     let token = localStorage.getItem("token")
//     if (token) {
//         req.headers.token = token;
//     }
//     return req;
// })
// //
// // //拦截响应,处理响应
// axios.interceptors.response.use(res => {
//     console.log("11111111111111111111111111111111111111111"+res)
//     let {success, message} = res.data
//     if (!success && message === 'noLogin') {
//         router.push({path: '/login'});
//     }
//     return res;
// })


// router.beforeEach((toRout, fromRout, next) => {
//     //NProgress.start();
//     console.log("跳转判断")
//     if (toRout.path == '/login') {
//         localStorage.removeItem('user');
//     }
//     // let user = JSON.parse(localStorage.getItem('user'));
//     let user = localStorage.getItem('user')
//     if (!user && toRout.path != '/login') {
//         next({path: '/login'})
//     } else {
//         next()
//     }
// })

//router.afterEach(transition => {
//NProgress.done();
//});

new Vue({
    //el: '#app',
    //template: '<App/>',
    router,
    store,
    //components: { App }
    render: h => h(App)
}).$mount('#app')

